<template>
  <div class="reception-dashboard">
    <!-- 顶部欢迎提示语 -->
    <div class="welcome-section">
      <h1 class="welcome-title">亲爱的{{ userInfo.name }}前台，欢迎回到智慧养老中心接待系统！</h1>
      <p class="welcome-subtitle">用心接待，用爱服务，让每一位来访者感受到家的温暖 🏠</p>
    </div>

    <!-- 今日数据概览 -->
    <div class="stats-section">
      <el-row :gutter="20">
        <el-col :span="6">
          <el-card class="stat-card">
            <div class="stat-content">
              <div class="stat-icon">👵</div>
              <div class="stat-info">
                <div class="stat-number">{{ stats.todayCheckin || 0 }}</div>
                <div class="stat-label">今日入住</div>
              </div>
            </div>
          </el-card>
        </el-col>
        <el-col :span="6">
          <el-card class="stat-card">
            <div class="stat-content">
              <div class="stat-icon">👋</div>
              <div class="stat-info">
                <div class="stat-number">{{ stats.todayCheckout || 0 }}</div>
                <div class="stat-label">今日退住</div>
              </div>
            </div>
          </el-card>
        </el-col>
        <el-col :span="6">
          <el-card class="stat-card">
            <div class="stat-content">
              <div class="stat-icon">👥</div>
              <div class="stat-info">
                <div class="stat-number">{{ stats.todayVisitor || 0 }}</div>
                <div class="stat-label">今日访客</div>
              </div>
            </div>
          </el-card>
        </el-col>
        <el-col :span="6">
          <el-card class="stat-card">
            <div class="stat-content">
              <div class="stat-icon">📞</div>
              <div class="stat-info">
                <div class="stat-number">{{ stats.todayCall || 0 }}</div>
                <div class="stat-label">今日来电</div>
              </div>
            </div>
          </el-card>
        </el-col>
      </el-row>
    </div>

    <!-- 接待功能模块 -->
    <div class="reception-section">
      <h3 class="section-title">接待中心</h3>
      <el-row :gutter="20">
        <el-col :span="8">
          <el-card class="reception-card" @click="$router.push('/dashboard/reception/checkin')">
            <div class="reception-icon">🏠</div>
            <h4>入住登记</h4>
            <p>为新入住老人办理登记手续</p>
            <div class="card-arrow">→</div>
          </el-card>
        </el-col>
        <el-col :span="8">
          <el-card class="reception-card" @click="$router.push('/dashboard/reception/checkout')">
            <div class="reception-icon">👋</div>
            <h4>退住办理</h4>
            <p>为退住老人办理相关手续</p>
            <div class="card-arrow">→</div>
          </el-card>
        </el-col>
        <el-col :span="8">
          <el-card class="reception-card" @click="$router.push('/dashboard/reception/visitor')">
            <div class="reception-icon">👥</div>
            <h4>访客管理</h4>
            <p>登记和管理来访人员信息</p>
            <div class="card-arrow">→</div>
          </el-card>
        </el-col>
        <el-col :span="8">
          <el-card class="reception-card" @click="$router.push('/dashboard/reception/outing')">
            <div class="reception-icon">🚶</div>
            <h4>外出管理</h4>
            <p>管理老人外出申请和记录</p>
            <div class="card-arrow">→</div>
          </el-card>
        </el-col>
        <el-col :span="8">
          <el-card class="reception-card" @click="$router.push('/dashboard/reception/outing-return')">
            <div class="reception-icon">🏃</div>
            <h4>归返管理</h4>
            <p>记录老人外出归返情况</p>
            <div class="card-arrow">→</div>
          </el-card>
        </el-col>
        <el-col :span="8">
          <el-card class="reception-card" @click="$router.push('/dashboard/reception/elder')">
            <div class="reception-icon">👵</div>
            <h4>老人信息</h4>
            <p>查看和管理老人基本信息</p>
            <div class="card-arrow">→</div>
          </el-card>
        </el-col>
      </el-row>
    </div>

    <!-- 今日待办事项 -->
    <div class="todo-section">
      <el-card class="todo-card">
        <template #header>
          <div class="todo-header">
            <i class="el-icon-tickets"></i>
            <span>今日待办</span>
          </div>
        </template>
        <div class="todo-content">
          <div class="todo-item" v-for="item in todoList" :key="item.id">
            <div class="todo-checkbox">
              <el-checkbox v-model="item.completed"></el-checkbox>
            </div>
            <div class="todo-info">
              <div class="todo-title" :class="{ 'completed': item.completed }">{{ item.title }}</div>
              <div class="todo-time">{{ item.time }}</div>
            </div>
            <div class="todo-priority" :class="item.priority">{{ item.priority }}</div>
          </div>
        </div>
      </el-card>
    </div>

    <!-- 服务理念 -->
    <div class="service-section">
      <el-card class="service-card">
        <div class="service-content">
          <div class="service-text">
            <h3>服务理念</h3>
            <p>"作为养老中心的前台，我们是温暖的传递者，是关怀的守护者。每一个微笑都承载着对长者的尊重，每一次服务都体现着专业的温度。"</p>
            <div class="service-principles">
              <div class="principle">
                <i class="el-icon-sunny"></i>
                <span>微笑服务</span>
              </div>
              <div class="principle">
                <i class="el-icon-lock"></i>
                <span>安全第一</span>
              </div>
              <div class="principle">
                <i class="el-icon-medal"></i>
                <span>专业高效</span>
              </div>
              <div class="principle">
                <i class="el-icon-heart"></i>
                <span>爱心关怀</span>
              </div>
            </div>
          </div>
          <div class="service-image">
            <div class="image-placeholder">
              <i class="el-icon-office-building"></i>
              <p>温馨接待</p>
            </div>
          </div>
        </div>
      </el-card>
    </div>

    <!-- 快速操作 -->
    <div class="quick-actions-section">
      <h3 class="section-title">快速操作</h3>
      <div class="quick-actions">
        <el-button type="primary" @click="$router.push('/dashboard/reception/checkin')" size="large">
          <i class="el-icon-house"></i>
          入住登记
        </el-button>
        <el-button type="success" @click="$router.push('/dashboard/reception/checkout')" size="large">
          <i class="el-icon-s-promotion"></i>
          退住办理
        </el-button>
        <el-button type="warning" @click="$router.push('/dashboard/reception/visitor')" size="large">
          <i class="el-icon-user"></i>
          访客登记
        </el-button>
        <el-button type="info" @click="$router.push('/dashboard/reception/outing')" size="large">
          <i class="el-icon-position"></i>
          外出管理
        </el-button>
      </div>
    </div>
  </div>
</template>

<script setup>
import { reactive, onMounted } from 'vue'
import axios from '@/api/axios'

// 用户信息
const userInfo = reactive(JSON.parse(localStorage.getItem('userInfo') || '{}'))

// 统计数据
const stats = reactive({
  todayCheckin: 0,
  todayCheckout: 0,
  todayVisitor: 0,
  todayCall: 0
})

// 待办事项
const todoList = reactive([
  { id: 1, title: '处理新入住老人登记', time: '09:00', priority: 'high', completed: false },
  { id: 2, title: '接待家属来访咨询', time: '10:30', priority: 'medium', completed: false },
  { id: 3, title: '更新老人外出记录', time: '14:00', priority: 'medium', completed: false },
  { id: 4, title: '整理今日入住资料', time: '16:30', priority: 'low', completed: false }
])

// 获取统计数据
const fetchStats = async () => {
  try {
    const res = await axios.get('/reception/index/data')
    Object.assign(stats, res.data)
  } catch (e) {
    console.log('数据加载失败，使用默认值')
    // 设置默认值
    stats.todayCheckin = 2
    stats.todayCheckout = 1
    stats.todayVisitor = 8
    stats.todayCall = 15
  }
}

onMounted(() => {
  fetchStats()
})
</script>

<style scoped>
.reception-dashboard {
  padding: 20px;
  max-width: 1200px;
  margin: 0 auto;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  min-height: 100vh;
}

.welcome-section {
  text-align: center;
  margin-bottom: 40px;
  padding: 40px 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 20px;
  color: white;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.welcome-title {
  font-size: 2.5em;
  margin-bottom: 15px;
  font-weight: 600;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.welcome-subtitle {
  font-size: 1.3em;
  opacity: 0.9;
  font-weight: 300;
}

.stats-section {
  margin-bottom: 40px;
}

.stat-card {
  border-radius: 15px;
  border: none;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
  transition: all 0.3s ease;
  background: white;
}

.stat-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.15);
}

.stat-content {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 20px;
}

.stat-icon {
  font-size: 3em;
  width: 60px;
  text-align: center;
}

.stat-info {
  flex: 1;
}

.stat-number {
  font-size: 2.5em;
  font-weight: bold;
  color: #2c3e50;
  margin-bottom: 5px;
}

.stat-label {
  color: #7f8c8d;
  font-size: 0.9em;
  font-weight: 500;
}

.reception-section {
  margin-bottom: 40px;
}

.section-title {
  color: #2c3e50;
  margin-bottom: 25px;
  font-size: 1.8em;
  font-weight: 600;
  text-align: center;
}

.reception-card {
  border-radius: 15px;
  border: none;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
  transition: all 0.3s ease;
  background: white;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  margin-bottom: 20px;
}

.reception-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.15);
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.reception-card:hover h4,
.reception-card:hover p {
  color: white;
}

.reception-card:hover .reception-icon {
  transform: scale(1.1);
}

.reception-card:hover .card-arrow {
  opacity: 1;
  transform: translateX(5px);
}

.reception-icon {
  font-size: 3em;
  margin-bottom: 15px;
  transition: all 0.3s ease;
}

.reception-card h4 {
  color: #2c3e50;
  margin-bottom: 10px;
  font-size: 1.3em;
  font-weight: 600;
  transition: color 0.3s ease;
}

.reception-card p {
  color: #7f8c8d;
  line-height: 1.5;
  margin-bottom: 15px;
  transition: color 0.3s ease;
}

.card-arrow {
  position: absolute;
  top: 20px;
  right: 20px;
  font-size: 1.5em;
  opacity: 0;
  transition: all 0.3s ease;
  color: white;
}

.todo-section {
  margin-bottom: 40px;
}

.todo-card {
  border-radius: 15px;
  border: none;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
  background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
}

.todo-header {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 1.2em;
  color: #2c3e50;
}

.todo-header i {
  font-size: 1.3em;
}

.todo-content {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.todo-item {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 15px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 10px;
  transition: all 0.3s ease;
}

.todo-item:hover {
  transform: translateX(5px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.todo-checkbox {
  flex-shrink: 0;
}

.todo-info {
  flex: 1;
}

.todo-title {
  font-weight: 500;
  margin-bottom: 5px;
  color: #2c3e50;
}

.todo-title.completed {
  text-decoration: line-through;
  color: #95a5a6;
}

.todo-time {
  color: #7f8c8d;
  font-size: 0.9em;
}

.todo-priority {
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 0.8em;
  font-weight: 500;
  color: white;
}

.todo-priority.high {
  background: #e74c3c;
}

.todo-priority.medium {
  background: #f39c12;
}

.todo-priority.low {
  background: #27ae60;
}

.service-section {
  margin-bottom: 40px;
}

.service-card {
  border-radius: 20px;
  border: none;
  background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.service-content {
  display: flex;
  align-items: center;
  gap: 40px;
  padding: 30px;
}

.service-text {
  flex: 1;
}

.service-text h3 {
  color: #2d3436;
  margin-bottom: 20px;
  font-size: 1.8em;
  font-weight: 600;
}

.service-text p {
  color: #2d3436;
  line-height: 1.6;
  margin-bottom: 25px;
  font-size: 1.1em;
  font-style: italic;
}

.service-principles {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 15px;
}

.principle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 8px;
  backdrop-filter: blur(10px);
}

.principle i {
  color: #74b9ff;
  font-size: 1.2em;
}

.principle span {
  color: #2d3436;
  font-weight: 500;
}

.service-image {
  flex-shrink: 0;
  width: 200px;
}

.image-placeholder {
  width: 100%;
  height: 150px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #636e72;
  border: 2px dashed rgba(99, 110, 114, 0.3);
}

.image-placeholder i {
  font-size: 2em;
  margin-bottom: 10px;
}

.quick-actions-section {
  margin-bottom: 30px;
}

.quick-actions {
  display: flex;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
}

.quick-actions .el-button {
  padding: 15px 25px;
  border-radius: 10px;
  font-weight: 500;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
}

.quick-actions .el-button:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

/* 响应式设计 */
@media (max-width: 768px) {
  .reception-dashboard {
    padding: 10px;
  }
  
  .welcome-title {
    font-size: 1.8em;
  }
  
  .welcome-subtitle {
    font-size: 1em;
  }
  
  .stat-content {
    flex-direction: column;
    text-align: center;
    gap: 10px;
  }
  
  .stat-icon {
    font-size: 2.5em;
  }
  
  .stat-number {
    font-size: 2em;
  }
  
  .service-content {
    flex-direction: column;
    gap: 20px;
  }
  
  .service-image {
    width: 100%;
  }
  
  .quick-actions {
    flex-direction: column;
    align-items: center;
  }
  
  .quick-actions .el-button {
    width: 100%;
    max-width: 300px;
  }
}
</style>
